# coding: utf-8
from PySide6.QtWidgets import QStackedWidget

from .class_list_interface import ClassListInterface
from .more_interface import MoreInterface


class ListingInterface(QStackedWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.isLoad = False
        self.classList = ClassListInterface(self)
        self.more = MoreInterface(self)

        self.setObjectName("ListingInterface")
        self.addWidget(self.classList)
        self.addWidget(self.more)
        self.setCurrentWidget(self.classList)

        self.classList.moreSignal.connect(self.onMoreSignal)
        self.more.closeSignal.connect(self.onMoreClose)

    def init(self):
        if not self.isLoad:
            self.classList.load()
            self.isLoad = True

    def onMoreSignal(self, spid):
        self.more.load(spid)
        self.setCurrentWidget(self.more)

    def onMoreClose(self):
        self.setCurrentWidget(self.classList)
